package xyz.chaobei.date;

import java.time.Clock;
import java.time.Instant;
import java.util.Date;

/**
 *
 * @author <a href='mailto:maruichao52@gmail.com'>MRC</a>
 * @since 2021/2/19
 */
public class ClockTest {

    public static void main(String[] args) {

        Clock clock = Clock.systemDefaultZone();

        long time = System.currentTimeMillis();
        long millis = clock.millis();

        // 获取当前时间戳 也就是毫秒数
        System.out.println("time=" + time);
        System.out.println("millis=" + millis);

        // 获取当前实例
        Instant instant = clock.instant();

        // 使用时间点创建旧版本Date
        Date date = Date.from(instant);
        System.out.println(date);
    }
}
